Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add filter function as an option to linkinator.check() #120

Merged
merged 6 commits into from
Nov 20, 2019

Conversation

zeke
Copy link
Contributor

@zeke zeke commented Nov 19, 2019

This PR adds a new filterLinks option to the linkinator.check function. The new option is a function that can be used to determine which URLs to skip and which to keep.

I'm not attached to the name of this option, nor the implementation. I'm open to alternatives ways of solving this that would expose the same level of flexibility to module users.

@ghost
Copy link

ghost commented Nov 19, 2019

There were the following issues with this Pull Request

  • Commit: bc60619
    • ✖ message may not be empty
    • ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

@zeke zeke changed the title add filterLinks option add filter function as an option to linkinator.check Nov 19, 2019
@zeke zeke changed the title add filter function as an option to linkinator.check feat: add filter function as an option to linkinator.check Nov 19, 2019
@zeke zeke changed the title feat: add filter function as an option to linkinator.check feat: add filter function as an option to linkinator.check() Nov 19, 2019
@marapper
Copy link
Contributor

Some alternative is making it like in babel/webpack or other tools. Existing flag linksToSkip (to be honest i'd rather prefer exclude/include naming) could be array or function.

Copy link
Owner

@JustinBeckwith JustinBeckwith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the naming feedback, this is great!

README.md Outdated Show resolved Hide resolved
@zeke
Copy link
Contributor Author

zeke commented Nov 20, 2019

Thanks for the feedback. I've updated this PR to allow linksToIgnore to be a function.

src/index.ts Outdated
@@ -16,7 +16,7 @@ export interface CheckOptions {
port?: number;
path: string;
recurse?: boolean;
linksToSkip?: string[];
linksToSkip?: string[] | ((link: string) => boolean);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be safe - can we make the function here async? I never think someone will need it, then they always end up needing it 😆

linksToSkip?: string[] | (async (link: string) => boolean);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I omitted the async because I was getting this error when I included it:

Screen Shot 2019-11-20 at 9 58 36 AM

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that's weird - is this VS Code? Alternatively, (link: string) => Promise<boolean> gets us to the same place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's VS Code.

I used your Promise<boolean> suggestion here and updated the tests and docs in a146f2c

src/index.ts Show resolved Hide resolved
@ghost
Copy link

ghost commented Nov 20, 2019

There were the following issues with this Pull Request

  • Commit: f1dfd01
    • ✖ message may not be empty
    • ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

Copy link
Owner

@JustinBeckwith JustinBeckwith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great now. Thank you!

@JustinBeckwith JustinBeckwith merged commit 8240159 into JustinBeckwith:master Nov 20, 2019
@JustinBeckwith
Copy link
Owner

🎉 This PR is included in version 1.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants